<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <title>微信安全支付</title>
    <link rel="stylesheet" href="__WEUI__/style/weui.css"/>
    <link rel="stylesheet" href="__WEUI__/example/example.css"/>

     {:think\\Hook::listen('jssdk',$myJssdk,null,true);}
    <script src="__JS__/jquery.min.js?v=2.1.4"></script>
</head>

  
 <body>
 <div class="page msg_success js_show">
    <div class="weui-msg">
        <div class="weui-msg__icon-area"><i class="weui-icon-success weui-icon_msg"></i></div>
        <div class="weui-msg__text-area">
            <h2 class="weui-msg__title">你将为{$pay.product}支付{$pay.price}元</h2>
            <p class="weui-msg__desc">{$pay.description}</p>
        </div>
        <div class="weui-msg__opr-area">
            <p class="weui-btn-area">
                <a onclick="callpay()" class="weui-btn weui-btn_primary">微信支付</a>
                <a onclick="wx.closeWindow()" class="weui-btn weui-btn_default">取消</a>
            </p>
        </div>
        <div class="weui-msg__extra-area">
            <div class="weui-footer">
                <p class="weui-footer__links">
                    <a href="javascript:void(0);" class="weui-footer__link">微信安全支付</a>
                </p>
                <p class="weui-footer__text">Copyright © 2008-2016 </p>
            </div>
        </div>
    </div>
</div>


 <script src="__WEUI__/example/zepto.min.js"></script>
 <script src="__WEUI__/example/weui.min.js"></script>
 <script src="__WEUI__/example/example.js"></script>
   
</body>
</html>


<script type="text/javascript">
        function callpay() {
           wx.chooseWXPay({                    // 调起支付
              timestamp: '{$jsApiParameters.timeStamp}', 
              nonceStr: '{$jsApiParameters.nonceStr}', 
              package:'{$jsApiParameters.package}', 
              signType: '{$jsApiParameters.signType}', 
              paySign: '{$jsApiParameters.paySign}', 
              success: function (res) {
                  callback();
                  console.log(res);
              },
              error : function() {
                  alert('支付失败');
              }
          });
        }

        function callback(){  
          $.ajax({
                  type:"post",
                  url:"{:url('we/pay/paySuccess')}",
                  data:{},
                  dataType:"text",
                  success:function(data){
                   var json = JSON.parse(data); 
                   console.log(json);
                   if(json.code==1){
                       alert('支付成功');
                       wx.closeWindow();
                    }
                   },
                  async:false
          });
        } 
</script>
</html>

